package com.example.demo;


import java.sql.*;
public class ConnBean {
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    static final String DB_URL = "jdbc:mysql://49.234.61.31:3306/lyj";
    static final String USER = "lyj";
    static final String PASS = "3waPAdMyHAxSM5SX";

    public static Connection getConn(){
        Connection conn=null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }

        try {
            conn= DriverManager.getConnection(DB_URL,USER,PASS);

        }catch (SQLException e){
            e.printStackTrace();
        }
        return conn;
    }

    public static void closeDB(ResultSet rs, PreparedStatement pstmt,Connection conn) {
        try {
            if (rs != null) {
                rs.close();
            }
            if (pstmt!=null){
                pstmt.close();
            }
            if (conn!=null){
                conn.close();
            }
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}